void ZtmWriteEpc()
{

	// TODO: Add your control notification handler code here

  /*DLL Function loading*/

	HINSTANCE gt1 = NULL;
	
	gt1=LoadLibrary("ZMPCL.dll");
	OpenPort = (fOpenPort)GetProcAddress(gt1,"OpenPort");
    ClosePort = (fClosePort)GetProcAddress(gt1,"ClosePort");
	ZM_DrawBarcode = (fZM_DrawBarcode)GetProcAddress(gt1,"ZM_DrawBarcode");
    ZM_SetLabelHeight = (fZM_SetLabelHeight)GetProcAddress(gt1,"ZM_SetLabelHeight");
    ZM_PrintLabel = (fZM_PrintLabel)GetProcAddress(gt1,"ZM_PrintLabel");
    ZM_SetDarkness = (fZM_SetDarkness)GetProcAddress(gt1,"ZM_SetDarkness");
    ZM_SetPrintSpeed = (fZM_SetPrintSpeed)GetProcAddress(gt1,"ZM_SetPrintSpeed");
	ZM_SetLabelWidth = (fZM_SetLabelWidth)GetProcAddress(gt1,"ZM_SetLabelWidth");
    ZM_ClearBuffer = (fZM_ClearBuffer)GetProcAddress(gt1,"ZM_ClearBuffer");
	ZM_DrawTextTrueTypeW = (fZM_DrawTextTrueTypeW)GetProcAddress(gt1,"ZM_DrawTextTrueTypeW");
	ZM_DrawLineOr = (fZM_DrawLineOr)GetProcAddress(gt1,"ZM_DrawLineOr");
	ZM_DrawText = (fZM_DrawText)GetProcAddress(gt1,"ZM_DrawText");
	ZM_DrawBar2D_QR = (fZM_DrawBar2D_QR)GetProcAddress(gt1,"ZM_DrawBar2D_QR");
	ZM_DrawBar2D_Pdf417 = (fZM_DrawBar2D_Pdf417)GetProcAddress(gt1,"ZM_DrawBar2D_Pdf417");
	ZM_PcxGraphicsDel  = (fZM_PcxGraphicsDel)GetProcAddress(gt1,"ZM_PcxGraphicsDel");
	ZM_PcxGraphicsDownload = (fZM_PcxGraphicsDownload)GetProcAddress(gt1,"ZM_PcxGraphicsDownload");
	ZM_DrawPcxGraphics = (fZM_DrawPcxGraphics)GetProcAddress(gt1,"ZM_DrawPcxGraphics");
	ZM_DrawRectangle  = (fZM_DrawRectangle)GetProcAddress(gt1,"ZM_DrawRectangle");

	ZM_SetPCComPort  = (fZM_SetPCComPort)GetProcAddress(gt1,"ZM_SetPCComPort");	//130718
	ZM_ErrorReport_USB = (fZM_ErrorReport_USB)GetProcAddress(gt1,"ZM_ErrorReport_USB");	//171010

	ZM_GetPrinterStatus_USB = (fZM_GetPrinterStatus_USB)GetProcAddress(gt1,"ZM_GetPrinterStatus_USB");	//171011

    ZM_ReadRFTagDataUSB = (fZM_ReadRFTagDataUSB)GetProcAddress(gt1,"ZM_ReadRFTagDataUSB");	//180104 add

	ZM_SetRFIDPosition = (fZM_SetRFIDPosition)GetProcAddress(gt1,"ZM_SetRFIDPosition");	//180105 add

	ZM_SetRFTagRetryCount = (fZM_SetRFTagRetryCount)GetProcAddress(gt1,"ZM_SetRFTagRetryCount");	//180105 add

    ZM_SetRFTagPassWLock = (fZM_SetRFTagPassWLock)GetProcAddress(gt1,"ZM_SetRFTagPassWLock");	//180105 add

	ZM_RW_RfidFormat = (fZM_RW_RfidFormat)GetProcAddress(gt1,"ZM_RW_RfidFormat");	//180105 add

	ZM_AutoRFTagDetc = (fZM_AutoRFTagDetc)GetProcAddress(gt1,"ZM_AutoRFTagDetc");	//180105 add

	ZM_SetRFIDReadWritePower = (fZM_SetRFIDReadWritePower)GetProcAddress(gt1,"ZM_SetRFIDReadWritePower");	//180108 add

	int i1 = 0;
	int errorcode = 99;
	char RFGetBuf[256] = { 0 };


        int prtNum = 1; //After manual paper measurement, print 1 label
    

	//Print Data Section
	for ( i1 = 0; i1 < prtNum ; i1++)  //Number of cycles
	{

	 /* ========================================================================================*/

		/****************************************************************
		* USB port printing function DEMO
		******************************************************************/
//First, open the port	
		errorcode = OpenPort(255);          // Open the USB port of the printer. To change the port, see the DLL manual;
		if (errorcode!=0)  {break;}
		//ZM_SetPCComPort(38400,TRUE);
		errorcode=ZM_ClearBuffer();  	             //Clear printer cache
		if (errorcode!=0)  {break;}

//#############################################################################3


//Second, common label format editing
		errorcode = ZM_SetLabelHeight (600,16);      // Set the label height and line gap size;
		if(errorcode != 0) {break;}
		errorcode = ZM_SetLabelWidth (800);          // Set the width of the label;
		if(errorcode != 0) {break;}
		errorcode = ZM_SetDarkness( 10 );            // Set the printer printing temperature;
		if(errorcode != 0) {break;}
		errorcode = ZM_SetPrintSpeed( 5 );           // Set the printer printing speed;

		// Draw Rectangle
		errorcode = ZM_DrawRectangle(50,10,3,460,340);
		if(errorcode != 0) {break;}

		// Draw table split line
		errorcode = ZM_DrawLineOr(60,108,402,3);
		if(errorcode != 0) {break;}

	#if 0	//130718     
		// Print PCX drawings
		errorcode = ZM_PcxGraphicsDel("PCX");
		if(errorcode != 0) {break;}
		errorcode = ZM_PcxGraphicsDownload("PCX","pic.pcx");
		if(errorcode != 0) {break;}
		errorcode = ZM_DrawPcxGraphics(80,30,"PCX");
		if(errorcode != 0) {break;}
	#endif

		// Print a 128 Auto barcode;
		errorcode = ZM_DrawBarcode(80, 208, 0, "1", 2, 2, 50, 'B', "123456789");
		if(errorcode != 0) {break;}

		// Print PDF417 code
		errorcode = ZM_DrawBar2D_Pdf417(80,300,400,300,0,0,3,7,10,2,0,0,"123456789");
		if(errorcode != 0) {break;}

		// Print QR code 120 ->20
		errorcode = ZM_DrawBar2D_QR(360,30,180,180,0,3,2,0,0, " Electronics Co., Ltd.");
		if(errorcode != 0) {break;}

		// Print built-in font dot matrix text
		errorcode = ZM_DrawText(80, 168, 0, 3, 1, 1, 'N', "Internal Font");
		if(errorcode != 0) {break;}

	#if 1	//130718
		//  Print the TrueType Font text of WINDDOS system;
		errorcode = ZM_DrawTextTrueTypeW (80, 120, 40, 0, "Arial", 1, 400, 0, 0, 0, "A1", "TrueType Font");
		if(errorcode != 0) {break;}

		// Print the TrueType Font text of WINDDOS system;
		errorcode = ZM_DrawTextTrueTypeW(420, 102, 22, 0, "Arial", 2, 400, 0, 0, 0, "A2", "www.ltznkj.cn");
		if(errorcode != 0) {break;}
	#endif


////RFID DEMO //////////////////////////////////////////////////////////////////////////////////////////////////////
//Third, RFID data writing, decryption, encryption and other operations
#if 1
	
	//Unlock EPC area with password 12345678 (HEX format)
    errorcode = ZM_SetRFTagPassWLock(0,2,"12345678" );	
	if (errorcode!=0 )  //Printer is not ready
	{		
		FreeLibrary(gt1);
		return;
	}


	//Write data in hexadecimal format to the EPC area. Write 12 bytes of data in total: "313030333731363045424149",
	errorcode = ZM_RW_RfidFormat(1,0,0,12,1,"313030333731363045424151");	//180105 add
	if (errorcode!=0 )  //Printer is not ready
	{		
		FreeLibrary(gt1);
		return;
	}

	//Set the lock password to 12345678 (HEX format) and lock the EPC area; 180105 add
    errorcode = ZM_SetRFTagPassWLock(1,2,"12345678" );	
	if (errorcode!=0 )  //Printer is not ready
	{		
		FreeLibrary(gt1);
		return;
	}


#endif

//Fifth, start printing
		errorcode=ZM_PrintLabel(1,1);
		if (errorcode!=0)  {break;}		

//Sixth, close the port
		ClosePort();
	}

	

	FreeLibrary(gt1);
}